package com.itheima.controller;
import com.itheima.pojo.BookCategory;
import com.itheima.pojo.Category;
import com.itheima.pojo.Result;
import com.itheima.service.BookCategoryService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/bookCategory")
public class BookCategoryController {
    @Resource
    private BookCategoryService bookCategoryService;

    @GetMapping
    public Result<List<BookCategory>> listBookCategory(){
        List<BookCategory> bookCategoryList = bookCategoryService.listBookCategry();
        return Result.success(bookCategoryList);
    }

    @PostMapping
    public Result addBookCategory(@RequestBody BookCategory bookCategory){
        int a=1;
        bookCategoryService.addBookCategory(bookCategory);
        return Result.success();
    }
    @PutMapping
    public Result updateBookCategory(@RequestBody BookCategory bookCategory){
        bookCategoryService.updateBookCategory(bookCategory);
        return Result.success();
    }

    @DeleteMapping
    public Result deleteBookCategory(@RequestParam Integer id){
        bookCategoryService.deleteBookCategory(id);
        return Result.success();
    }


}
